package com.tang.websocket.v1.message;

import com.alibaba.fastjson.JSONObject;

/**
 * @author Tang
 * @classname PingMessage
 * @description [ PING ]
 * @date 2022/11/29 10:08
 */
public class PingMessage extends WebSocketMessage<String> {

    public static PingMessage INSTANCE = new PingMessage();

    public PingMessage() {
        super("PING");
        this.cmd = getCmd();
    }

    @Override
    public Integer getCmd() {
        return 0;
    }

    public static boolean isPing(String msg) {
        return Integer.parseInt(JSONObject.parseObject(msg).get("cmd").toString()) == INSTANCE.getCmd();
    }
}
